package abstracttransaction

import (
	"fmt"
	"log"
	Database "salarypayment-case/DataBase"
	"strconv"
)

type ChangeEmployeeTransaction struct {
	EmployeeTransaction
	itsEmpid int
}

func (ce *ChangeEmployeeTransaction) SetEmpid(empid int) {
	ce.itsEmpid = empid
}

func (ce *ChangeEmployeeTransaction) Execute() {
	e := Database.PayrollDatabases.GetEmployee(ce.itsEmpid)

	if e != nil {
		ce.Change(e)
	} else {
		err := fmt.Errorf(Database.PayrollExceptionMessage.EmployeeNotExist + strconv.Itoa(ce.itsEmpid))
		log.Println(err.Error())
		return
	}

}
